#include <stdio.h>
#include <string.h>
#include <conio.h>
#include "Directories.h"
#ifdef __CBM__
#include <cbm.h>
#endif

#ifdef __CBM__
int executeCommand(char device, char drive, const char *command)
{
	static char cmdBuffer[85];
	static int result;

	sprintf(cmdBuffer, "%u:%s", drive, command);
	result = cbm_open(15, device, 15, cmdBuffer);

	cbm_close(15);

	return result;
}
#endif

int enterDirectory(dirInfo_t *directory)
{
	return strlen(directory->enterDirectoryCommand) > 0 ? executeCommand(directory->device, directory->drive, directory->enterDirectoryCommand) : 0;
}

int leaveDirectory(dirInfo_t *directory)
{
	return strlen(directory->leaveDirectoryCommand) > 0 ? executeCommand(directory->device, directory->drive, directory->leaveDirectoryCommand) : 0;
}
